class MyRunnable implements Runnable{

    @Override
    public void run() {
        while (true){
            System.out.println(Thread.currentThread().getName()+"hello thread");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
public class demo02 {
    public static void main(String[] args) {
        Thread t = new Thread(new MyRunnable());
        t.setName("thread线程");
        t.start();
        while (true){
            System.out.println("hello main");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
